#include <iostream>
#include <algorithm>
using namespace std;
const int N = 1e6 + 10;
typedef long long LL;
LL a[N];
LL n, m;

LL calc(LL len)
{
    LL ret = 0;
    for(int i = 1;i <= n;i++)
    {
        if(a[i] <= len) continue;
        ret += a[i] - len;
    }

    return ret;
}

int main()
{
    cin >> n >> m;
    // LL maxlen = 0;
    for(int i = 1;i <= n;i++)
    {
        cin >> a[i];
        // maxlen = max(maxlen, a[i]);
    }

    // LL l = 1, r = maxlen;
    LL l = 1, r = 1e9;
    while(l < r)
    {
        LL mid = l + (r - l + 1) / 2;
        if(calc(mid) >= m) l = mid;
        else r = mid - 1;
    }

    cout << l << endl;
    return 0;
}